<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class admin_contact_model extends CI_Model
{

    public function __construct()
    {
        // Call the Model constructor
        parent::__construct();        
    }     

    function get_count_contact($type, $status = null){ 
    	$return = array();
    	$this->db->select('*')->from('landing_contact')->where('type',$type);   
    	$rs = $this->db->get();	
    	if ($rs->num_rows() == 0) {
            $rs->free_result();
            return false;
        } else {
            $return = $rs->result_array();            
            $rs->free_result();
            return $return;                                 
        }      	                         
    }
    
    function get_all_contact($start, $limit, $type, $status = null )
    {    	
        $this->db->select('*');
        $this->db->from('landing_contact');                    
        if($status){
        	$this->db->where('status',$status);
        }
        $this->db->where('type',$type);
        $this->db->limit($limit, $start);
        $rs = $this->db->get();
    	if ($rs->num_rows() == 0) {
            $rs->free_result();
            return false;
        } else {
            $return = $rs->result_array();            
            $rs->free_result();            
            return $return;
        }
    }   
    
    function update_contact($data){    	
    	$this->db->where('id', $data['id']);
    	return $this->db->update('landing_contact',$data);
    }
    
	function delete_contact($id){		
   		return $this->db->delete('landing_contact',array('id' => $id));
    }
}